package com.ethink.order.facadeImpl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ethink.order.api.SaleDemandOrderFacade;
import com.ethink.order.api.info.SaleDemandOrderDetailInfo;
import com.ethink.order.api.info.SaleDemandOrderInfo;
import com.ethink.order.api.info.SaleDemandOrderModeInfo;
import com.ethink.order.api.model.PreSuppleOrderDetailModel;
import com.ethink.order.api.request.*;
import com.ethink.order.api.response.SaleConfirmPurchaseResponse;
import com.ethink.order.api.response.SaleDemandOrderAddResponse;
import com.ethink.order.api.response.SaleDemandOrderDeleteResponse;
import com.ethink.order.api.response.SaleDemandOrderDetailResponse;
import com.ethink.order.manager.SaleDemandManager;
import com.ethink.order.service.SaleDemandOrderDetailService;
import com.ethink.order.service.SaleDemandOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 销售需求单 Facade接口实现
 *
 * @author default
 * @date 2022-10-31
 */
@RestController
@Slf4j
@RequestMapping("order-service/facade/v1/saleDemandOrder")
public class SaleDemandOrderFacadeImpl implements SaleDemandOrderFacade {

    @Autowired
    @Resource
    private SaleDemandOrderService saleDemandOrderService;

    @Autowired
    private SaleDemandOrderDetailService saleDemandOrderDetailService;

    @Autowired
    private SaleDemandManager saleDemandManager;

    @Override
    public Page<SaleDemandOrderInfo> querySaleDemandOrder(SaleDemandOrderQueryRequest request) {
        return saleDemandOrderService.querySaleDemandOrder(request);
    }

    @Override
    public SaleDemandOrderDetailResponse getSaleDemandOrderByNo(String orderNo) {
        return saleDemandOrderService.getSaleDemandOrderByNo(orderNo);
    }

    @Override
    public List<SaleDemandOrderInfo> listSaleDemandOrder(SaleDemandOrderQueryRequest request) {
        return saleDemandOrderService.listSaleDemandOrder(request);
    }

    @Override
    public SaleDemandOrderAddResponse addSaleDemandOrder(SaleDemandOrderAddRequest request) {
        return saleDemandOrderService.addSaleDemandOrder(request);
    }

    @Override
    public SaleDemandOrderDeleteResponse deleteSaleDemandOrder(Long saleDemandOrderId) {
        return saleDemandOrderService.deleteSaleDemandOrder(saleDemandOrderId);
    }

    @Override
    public void demandConfirm(SaleDemandOrderConfirmRequest request) {
        saleDemandOrderDetailService.demandConfirm(request);
}

    @Override
    public void lock(SaleDemandOrderLockRequest request) {
        saleDemandManager.lock(request);
    }

    @Override
    public void unlock(Long id) {
        saleDemandManager.unlock(id);
    }

    @Override
    public SaleConfirmPurchaseResponse oaPass(OAPassRequest request) {
        return saleDemandManager.oaPass(request);

    }

    @Override
    public Page<PreSuppleOrderDetailModel> pageQueryByPreSupple(PreSupplePageQueryRequest request) {
        return saleDemandOrderService.pageQueryByPreSupple(request);
    }

    @Override
    public String update(SaleDemandOrderUpdateRequest request) {
        return saleDemandOrderService.update(request);
    }

    @Override
    public Integer updateRemark(SaleDemandUpdateRemarkRequest request) {
        return saleDemandOrderService.updateRemark(request);
    }

    @Override
    public Integer demandConfirmUpdate(SaleDemandOrderUpdateConfirmRequest request) {
        return saleDemandManager.demandConfirmUpdate(request);
    }

    @Override
    public SaleDemandOrderInfo queryMainByOrderNo(String orderNo) {
        return saleDemandOrderService.queryMainByOrderNo(orderNo);
    }

    @Override
    public SaleDemandOrderDetailInfo queryItemByDetailOrderNo(String detailOrderNo) {
        return saleDemandOrderDetailService.queryItemByDetailOrderNo(detailOrderNo);
    }

    @Override
    public SaleDemandOrderInfo queryMainByDetailId(Long id) {
        return saleDemandOrderDetailService.queryMainByDetailId(id);
    }

    @Override
    public SaleDemandOrderDetailInfo queryDetailByDetailId(Long id) {
        return saleDemandOrderDetailService.getSaleDemandOrderDetailById(id);
    }

    @Override
    public Page<SaleDemandOrderModeInfo> querySaleDemandOrderMode(SaleDemandOrderQueryModeRequest request) {
        return saleDemandOrderService.querySaleDemandOrderMode(request);
    }
}